package com.demo.steammanagement.common;

import java.time.Duration;
import java.time.LocalDateTime;

public class DateUtils {

	public static LocalDateTime dataPlus(LocalDateTime date, long minutes, boolean isResetDate) {
		if (date != null) {
			if (isResetDate) {
				LocalDateTime now = LocalDateTime.now();
		        return now.plus(Duration.ofMinutes(minutes));
			} else {
		        return date.plus(Duration.ofMinutes(minutes));
			}
		} else {
	        LocalDateTime now = LocalDateTime.now();
	        return now.plus(Duration.ofMinutes(minutes));
		}
	}
	
	public static long between(LocalDateTime date) {
		LocalDateTime now = LocalDateTime.now();
		Duration duration = Duration.between(now, date);
		return duration.toMinutes();
	}
	
	public static boolean isLessThanCurrentTime(LocalDateTime date) {
	 LocalDateTime now = LocalDateTime.now();
	 if (date.isBefore(now)) {
            return true;
        } else {
        	return false;
        }
	}
}
